/*
 * @Author: funlee 
 * @Email: i@funlee.cn 
 * @Date: 2017-12-11 17:48:15 
 * @Last Modified time:   2017-12-11 17:48:15 
 * @Description: 适配区域
 *               fit(geometryOrExtent, opt_options)
 */
import ol from 'openlayers'
import 'openlayers/dist/ol.css'

export default () => {
  var map = new ol.Map({
    layers: [
      new ol.layer.Tile({
        source: new ol.source.OSM()
      })
    ],
    view: new ol.View({
      // 设置成都为地图中心
      center: [104.06, 30.67],
      projection: 'EPSG:4326',
      zoom: 10
    }),
    target: 'map'
  });

  document.querySelector('.fitCD').addEventListener('click', function () {
    map.getView().fit([104, 30.6, 104.12, 30.74],{
      callback:function() {
        console.log(888)
      }
    })
  })

  document.querySelector('.fitBJ').addEventListener('click', function () {
    console.log(map.getView().getCenter())
    var view = map.getView()
    view.setCenter([116.28437139081545, 39.87679068470133])
    map.render()
  })
}